<?php namespace Home\Controller; 



//测试控制器
class IndexController extends CommonController{

	//构造函数
	public function __init()
	{
	}
    public function index()
    {
   		$data = Db::table("article")
   			  ->join("category","category.cid","=","article.category_cid")
			  ->where("is_recycle",0)
   			  ->get();
		//p($data);die;
		//获得标签
		foreach($data as $k=>$v){
			$data[$k]['total'] = Db::table("article_tag")
				 ->join("tag","tag_tid","=","tid")
				 ->where("article_aid",$v['aid'])
				 ->lists("tid,tname");
			/*foreach($tag as $value){
				$tags = Db::table("tag")->where('tid','$value')->pluck("cname");
			}*/
			//p($tag);
		}
		//p($data);die;
		
		View::with('data',$data);
        View::make();
    }
}
